unit ReaderCards;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DATADIC, Db, Grids, DBGrids, IBCustomDataSet, DataEdit;

type
  TfmReaderCards = class(TfmDataDic)
    procedure FormCreate(Sender: TObject);
    procedure DBGridDrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    function Execute(ReaderID: integer; DicMode: TDicMode = dmView;
                 Editor: TfmDataEdit = nil): TModalResult;
  end;

var
  fmReaderCards: TfmReaderCards;

implementation
uses DataModule;
{$R *.DFM}

function TfmReaderCards.Execute(ReaderID: integer; DicMode: TDicMode;
  Editor: TfmDataEdit): TModalResult;
begin
  with TIBDataSet(FDataSet) do begin
    Close;
    ParamByName('reader_id').AsInteger :=  ReaderID;
  end;
  result := inherited Execute(DicMode, Editor);
end;

procedure TfmReaderCards.FormCreate(Sender: TObject);
begin
  inherited;
  DataSet := dmData.dsReaderCards;
end;

procedure TfmReaderCards.FormShow(Sender: TObject);
begin
  inherited;
  Dataset.Last;

end;

procedure TfmReaderCards.DBGridDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
  with (Sender as TDBGrid) do begin
    if DataSource.DataSet.FieldByName('OUTDATED').AsInteger = 1 then
      Canvas.Font.Color := clRed;
    DefaultDrawColumnCell(Rect, DataCol, Column, State);
  end;
end;

end.
